//package com.shenfc.card.subscriber;
//
//import org.springframework.context.annotation.Bean;
//import org.springframework.context.annotation.Configuration;
//import org.springframework.data.redis.connection.RedisConnectionFactory;
//import org.springframework.data.redis.listener.PatternTopic;
//import org.springframework.data.redis.listener.RedisMessageListenerContainer;
//import org.springframework.data.redis.listener.adapter.MessageListenerAdapter;
//
///**
// * 作者：沈飞超
// * 功能描述：
// * 创建日期：2018/4/2 14:15
// */
//@Configuration
//public class RedisSubscriber {
//
//    /**
//     * 创建连接工厂
//     * @param connectionFactory
//     * @param listenerAdapter
//     * @return
//     */
//    @Bean
//    public RedisMessageListenerContainer container(RedisConnectionFactory connectionFactory,
//                                                   MessageListenerAdapter listenerAdapter,MessageListenerAdapter listenerAdapter2){
//        RedisMessageListenerContainer container = new RedisMessageListenerContainer();
//        container.setConnectionFactory(connectionFactory);
//        container.addMessageListener(listenerAdapter,new PatternTopic("phone"));
//        container.addMessageListener(listenerAdapter2,new PatternTopic("phone"));
//        return container;
//    }
//
//    /**
//     * 绑定消息监听者和接收监听的方法
//     * @param receiver
//     * @return
//     */
//    @Bean
//    public MessageListenerAdapter listenerAdapter(Receiver receiver){
//        return new MessageListenerAdapter(receiver,"receiveMessage");
//    }
//
//    @Bean
//    public MessageListenerAdapter listenerAdapter2(Receiver2 receiver2){
//        return new MessageListenerAdapter(receiver2,"receiveMessage2");
//    }
//    /**
//     * 注册订阅者
//     * @return
//     */
//    @Bean
//    public Receiver receiver(){
//        return new Receiver();
//    }
//    @Bean
//    public Receiver2 receiver2(){
//        return new Receiver2();
//    }
//}
